package com.suyx.job.job;

import org.apache.commons.lang3.StringUtils;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.suyx.job.entity.JobInfo;
import com.suyx.job.utils.CommandUtils;

import lombok.extern.slf4j.Slf4j;

/**
 * @Auther: lanyanhua
 * @Date: 2018/10/17 0017 14:45
 * @Description:
 */
@Slf4j
public class ClickExecuteJob implements Job {
    protected JobInfo jobInfo ;
    private int i = 0;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        log.info("进入了---testJob : " + ++i);
        // 713 110
		
        JobDataMap param = jobExecutionContext.getMergedJobDataMap();
        jobInfo = (JobInfo) param.get("jobInfo");
        String subject = "项目：" + jobInfo.getJobGroup() + ",执行任务：" + jobInfo.getJobName();
        log.info("id:" + jobInfo.getJobId() + "," + subject);
        String introduce = jobInfo.getIntroduce();
        if(StringUtils.isNotBlank(introduce)){
        	CommandUtils.excuteCommand(introduce);
        }
        log.info("执行完成~");
    }


}
